\section{network::connection\_\-manager Class Reference}
\label{classnetwork_1_1connection__manager}\index{network::connection_manager@{network::connection\_\-manager}}
This class is a facade to the whole network-functionality in this namespace.  


{\tt \#include $<$connection\_\-manager.h$>$}

Inheritance diagram for network::connection\_\-manager::\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2cm]{classnetwork_1_1connection__manager}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
\bf{connection\_\-manager} (boost::shared\_\-ptr$<$ \bf{message\_\-queue} $>$ q)
\begin{CompactList}\small\item\em \doxyref{connection\_\-manager}{p.}{classnetwork_1_1connection__manager} is the constructor of the \doxyref{connection\_\-manager}{p.}{classnetwork_1_1connection__manager} class. It is initialized with a message\_\-queue. \item\end{CompactList}\item 
\bf{$\sim$connection\_\-manager} ()\label{classnetwork_1_1connection__manager_ec2f1ade8e01aee44c4df364f65f6d02}

\item 
void \bf{add\_\-recv} (boost::shared\_\-ptr$<$ \bf{network::i\_\-socket} $>$ sock, boost::shared\_\-ptr$<$ \bf{network::filetype} $>$ file)
\begin{CompactList}\small\item\em add\_\-recv adds a new receiver to the network-system. \item\end{CompactList}\item 
boost::shared\_\-ptr$<$ \bf{network::i\_\-socket} $>$ \bf{add\_\-listener} (int port)
\begin{CompactList}\small\item\em add\_\-listener adds a new tcp-connection\_\-listener to the network-system. \item\end{CompactList}\item 
boost::shared\_\-ptr$<$ \bf{network::sender} $>$ \bf{get\_\-sender} (boost::shared\_\-ptr$<$ \bf{network::i\_\-socket} $>$ sock)
\begin{CompactList}\small\item\em get\_\-sender finds the appropriate file\_\-type for a socket. If you want to send something over a socket, you should use this method to get the appropriate file\_\-type, to convert your dom-structure to a string. \item\end{CompactList}\item 
virtual void \bf{notify} (const \bf{network::notifier} $\ast$n)
\begin{CompactList}\small\item\em notify is called from receiver, which want to be removed from the internal collection. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
This class is a facade to the whole network-functionality in this namespace. 



Definition at line 47 of file connection\_\-manager.h.

\subsection{Constructor \& Destructor Documentation}
\index{network::connection_manager@{network::connection\_\-manager}!connection_manager@{connection\_\-manager}}
\index{connection_manager@{connection\_\-manager}!network::connection_manager@{network::connection\_\-manager}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}network::connection\_\-manager::connection\_\-manager (boost::shared\_\-ptr$<$ \bf{message\_\-queue} $>$ {\em q})\hspace{0.3cm}{\tt  [inline]}}\label{classnetwork_1_1connection__manager_f76e1e92d620cf559e445467b7c0f24e}


\doxyref{connection\_\-manager}{p.}{classnetwork_1_1connection__manager} is the constructor of the \doxyref{connection\_\-manager}{p.}{classnetwork_1_1connection__manager} class. It is initialized with a message\_\-queue. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em q}]is a shared\_\-ptr of a message\_\-queue. \end{description}
\end{Desc}


Definition at line 56 of file connection\_\-manager.h.

\begin{Code}\begin{verbatim}57                 : _queue(q) {}
\end{verbatim}\end{Code}




\subsection{Member Function Documentation}
\index{network::connection_manager@{network::connection\_\-manager}!add_listener@{add\_\-listener}}
\index{add_listener@{add\_\-listener}!network::connection_manager@{network::connection\_\-manager}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}boost::shared\_\-ptr$<$ \bf{network::i\_\-socket} $>$ network::connection\_\-manager::add\_\-listener (int {\em port})}\label{classnetwork_1_1connection__manager_eb914b24fc902650d389fee3dfcaec0e}


add\_\-listener adds a new tcp-connection\_\-listener to the network-system. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em port}]is the port at which the listener should listen\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]the created listener-socket is returned, which can be used in user\_\-handlers. \end{Desc}


Definition at line 41 of file connection\_\-manager.cpp.

\begin{Code}\begin{verbatim}43 {
44         boost::shared_ptr<network::tcp_socket> sock(new network::tcp_socket());
45         sock->bind(port);
46         boost::mutex::scoped_lock l(_mutex);
47         boost::shared_ptr<network::connection_listener> list(new
48                 network::connection_listener(sock, _queue));
49         _listener.push_back(list);
50         list->start_thread();
51         return sock;
52 }
\end{verbatim}\end{Code}


\index{network::connection_manager@{network::connection\_\-manager}!add_recv@{add\_\-recv}}
\index{add_recv@{add\_\-recv}!network::connection_manager@{network::connection\_\-manager}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void network::connection\_\-manager::add\_\-recv (boost::shared\_\-ptr$<$ \bf{network::i\_\-socket} $>$ {\em sock}, boost::shared\_\-ptr$<$ \bf{network::filetype} $>$ {\em file})}\label{classnetwork_1_1connection__manager_a1e78c9cc885a58da198b582036b1112}


add\_\-recv adds a new receiver to the network-system. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em sock}]is the socket from which messages should be received. \item[{\em file}]is the filetype, which are received from sock \end{description}
\end{Desc}


Definition at line 25 of file connection\_\-manager.cpp.

\begin{Code}\begin{verbatim}28 {
29         boost::mutex::scoped_lock l(_mutex);
30         boost::shared_ptr<network::receiver> recv(network::receiver::create(
31                                                         sock, 
32                                                         _queue, 
33                                                         file));
34         boost::shared_ptr<network::listener> list(this, core::null_deleter());
35         recv->add_listener(list);
36         _receiver.push_back(recv);
37         _sender[sock] = file;
38         recv->start_thread();
39 }
\end{verbatim}\end{Code}


\index{network::connection_manager@{network::connection\_\-manager}!get_sender@{get\_\-sender}}
\index{get_sender@{get\_\-sender}!network::connection_manager@{network::connection\_\-manager}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}boost::shared\_\-ptr$<$ \bf{network::sender} $>$ network::connection\_\-manager::get\_\-sender (boost::shared\_\-ptr$<$ \bf{network::i\_\-socket} $>$ {\em sock})}\label{classnetwork_1_1connection__manager_eb37f2f7b7838dc5deb548ceb9980506}


get\_\-sender finds the appropriate file\_\-type for a socket. If you want to send something over a socket, you should use this method to get the appropriate file\_\-type, to convert your dom-structure to a string. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em sock}]is the socket, to which you want to send something\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]a shared\_\-ptr of \doxyref{network::sender}{p.}{classnetwork_1_1sender} is returned. \end{Desc}


Definition at line 54 of file connection\_\-manager.cpp.

\begin{Code}\begin{verbatim}56 {
57         boost::mutex::scoped_lock l(_mutex);
58         return _sender[sock];
59 }
\end{verbatim}\end{Code}


\index{network::connection_manager@{network::connection\_\-manager}!notify@{notify}}
\index{notify@{notify}!network::connection_manager@{network::connection\_\-manager}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void network::connection\_\-manager::notify (const \bf{network::notifier} $\ast$ {\em n})\hspace{0.3cm}{\tt  [virtual]}}\label{classnetwork_1_1connection__manager_6d39c9057d85a5a64df972486ff3169f}


notify is called from receiver, which want to be removed from the internal collection. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em n}]is a pointer to a \doxyref{network::receiver}{p.}{classnetwork_1_1receiver}. \end{description}
\end{Desc}


Implements \bf{network::listener} \doxyref{p.}{classnetwork_1_1listener_d26c010ecaab2a6eb7db4c0e4b40709a}.

Definition at line 61 of file connection\_\-manager.cpp.

\begin{Code}\begin{verbatim}62 {
63         boost::mutex::scoped_lock l(_mutex);
64         // remove the listener
65         typedef list<boost::shared_ptr<network::receiver> >::iterator it;
66         it i = _receiver.begin();
67         it next = _receiver.begin();
68         while(i != _receiver.end()) {
69                 ++next;
70                 if((*i).get() == n) {
71                         // hack!!11
72                         _sender.erase(boost::
73                                 const_pointer_cast<network::i_socket>(
74                                 (*i)->get_socket()));
75                         _receiver.erase(i);
76                 }
77                 i = next;
78         }
79 }
\end{verbatim}\end{Code}




The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
network/connection\_\-manager.h\item 
network/connection\_\-manager.cpp\end{CompactItemize}
